package com.ms.p2p.service.impl;


import com.ms.p2p.dao.LoanCategoryDao;
import com.ms.p2p.entity.loan.LoanCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  项目类型
 */
@Service
public class LoanCategoryServiceImpl {


	@Autowired
	LoanCategoryDao borrowCategoryDao;
	/**
	 * 增
	 * 
	 * @param map
	 * @return 插入主键
	 */


	@CacheEvict(value = "borrowcategory", allEntries = true)
	public int insert(LoanCategory map) {
		return borrowCategoryDao.insert(map);

	}

	/**
	 * 删
	 * 
	 * @param id
	 *            主键
	 * @return 受影响行数
	 */
	@CacheEvict(value = "borrowcategory", allEntries = true)
	public int delete(int id) {

		return borrowCategoryDao.deleteById(id);

	}

	/**
	 * 改
	 * 
	 * @param map
	 * @return 受影响行数
	 */
	@CacheEvict(value = "borrowcategory", allEntries = true)
	public int update(LoanCategory map) {
		return borrowCategoryDao.update(map);
	}

	/**
	 * 根据ID查
	 * 
	 * @return BorrowType实体类
	 */
	@Cacheable(value="borrowcategory",key="'id'+#id")
	public LoanCategory findById(String id) {
		return (LoanCategory) borrowCategoryDao.get(id);

	}

	/**
	 * 查所有
	 * 
	 * @return BorrowType 实体类集合
	 */
	@Cacheable(value="borrowcategory")
	public List<LoanCategory> findAll() {
		return  borrowCategoryDao.findAll();
	}


}
